-
Notifications
You must be signed in to change notification settings - Fork 112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Solve panic issues #275
Solve panic issues #275
Conversation
Codecov ReportPatch coverage:
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## master #275 +/- ##
==========================================
+ Coverage 73.50% 73.70% +0.20%
==========================================
Files 43 43
Lines 2291 2282 -9
==========================================
- Hits 1684 1682 -2
+ Misses 377 369 -8
- Partials 230 231 +1
☔ View full report in Codecov by Sentry. |
What do you think about creating a For exmaple:
Let me know what you think about it. |
When you define spec, it will panic if you have a composite field with invalid spec. So, Panicking in Go is generally reserved for situations where it's inappropriate or impossible for the program to continue. In our case, if the spec is not valid, we can't proceed. I believe using |
By default I agree on that usage of panic and I'm not trying to push my point of view, but I would like to share some argument to add an exported function with error return. (Note, I don't want to remove the original behavior, I'm just suggesting a minor extension) First I would like to highlight the usage of the library. By following the original documentation located in the README, we call the
Based on these arguments I hope you can reconsider the suggestion above. |
I want to understand what you're asking us to reconsider. Are you asking that methods like |
@adamdecaf |
@adamdecaf The main issue with the NewMessage that it has a lots of unexported part. So I can't write a function which is not relying on panic. Also I understand if you don't want to add such a change, but I thought I try it. :) |
I don't think supporting backwards compatibility of panics is something we want to support. Causing a |
I don't want to pick a side in this question, I just offered a possible solution where the caller of the library can decide between the backward compatible way or using another function with error return. Otherwise I wrote a wrapper solution to avoid panic for our use-case. So I'm also fine with the current implementation as well. |
Closes #269
With this PR we:
Validate()
method forMessageSpec
andfield.Spec
- so if you don't want constructor to panic, you can validate your spec before.StringsByHex
if sorted value is not a Hex, we compare them as regular strings (nopanic
)panic
in fuzzer, I hope later we can address it